from multiprocessing import Process
import os


val = None                  # global value
arr = [None, None, None]    # global container


def worker(n):
    global val

    print('worker, pid:', os.getpid(), 'id:', id(worker))
    print('original val:', val, 'id:', id(val))
    val = n
    print('modified val:', val, 'id:', id(val))
    
    func()
    test_arr(n)


def func():
    print('func, pid:', os.getpid(), 'id:', id(func))
    

def test_arr(n):
    global arr
    print()
    print('test arr')
    print('original arr: {}, id:{}'.format(arr, id(arr)))
    arr[0] = n
    print('modified arr: {}, id:{}'.format(arr, id(arr)))
    


if __name__ == '__main__':
    
    print('---------- main process ----------')
    worker(32)
    print('val:', val)
    
    print()
    print('---------- start sub process ----------')
    proc = Process(target=worker, args=(42, ))
    proc.start()
    
    proc.join()
    print('val at main:', val)

